package com.activity.bean;

import android.os.Build;
import android.view.View;

import org.apache.commons.lang3.StringUtils;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.List;

import androidx.annotation.RequiresApi;

public class RemarkBean {

    /**
     * usericon : https://exmobile.oss-cn-shanghai.aliyuncs.com/usericon/20190520092401736411.jpg
     * replycontent : %E8%AF%97%E8%AF%8D%E6%AD%8C%E8%B5%8B
     * replyid : 3
     * replyaddtime : 2019-06-25 07:29:58
     * replylist : [{"replyparentid":"3","usericon":"","replycontent":"%E5%9B%9E%E5%A4%8D%E5%86%85%E5%AE%B9","replyid":"4","replyaddtime":"2019-06-25 07:31:52","replyuserid":"2","replyworksid":"1","usernickname":"13681998586"}]
     * replyuserid : 1
     * replyworksid : 1
     * usernickname : 18616801156
     */

    private String usericon;
    private String replycontent;
    private String replyid;
    private String replyaddtime;
    private String replyuserid;
    private String replyworksid;
    private String usernickname;


    private List<ReplylistBean> replylist;

    public String getUsericon() {
        return usericon;
    }

    public void setUsericon(String usericon) {
        this.usericon = usericon;
    }

    public String getReplycontent() {
        try {
            String strUTF8 = URLDecoder.decode(replycontent, "UTF-8");
            return strUTF8;
        } catch (UnsupportedEncodingException e) {
            return replycontent;
        }

    }

    public void setReplycontent(String replycontent) {
        this.replycontent = replycontent;
    }

    public String getReplyid() {
        return replyid;
    }

    public void setReplyid(String replyid) {
        this.replyid = replyid;
    }

    public String getReplyaddtime() {
        return replyaddtime;
    }

    public  String getReplayListString() {
        if (getReplylist() != null && getReplylist().size() > 0) {

            ArrayList <String> list = new ArrayList<>();

            for (int i=0;i<replylist.size();i++){
                list.add(replylist.get(i).getReplyString());
            }

            return StringUtils.join(list,"\n");


        } else {
            return "";
        }



    }


    public void setReplyaddtime(String replyaddtime) {
        this.replyaddtime = replyaddtime;
    }

    public String getReplyuserid() {
        return replyuserid;
    }

    public void setReplyuserid(String replyuserid) {
        this.replyuserid = replyuserid;
    }

    public String getReplyworksid() {
        return replyworksid;
    }

    public void setReplyworksid(String replyworksid) {
        this.replyworksid = replyworksid;
    }

    public String getUsernickname() {
        return com.example.apple.ddhr_new.utils.StringUtil.utfString(usernickname);

    }

    public void setUsernickname(String usernickname) {
        this.usernickname = usernickname;
    }

    public List<ReplylistBean> getReplylist() {
        if(replylist==null)
            replylist =new ArrayList<>();
        return replylist;
    }

    public void setReplylist(List<ReplylistBean> replylist) {
        this.replylist = replylist;
    }

    public static class ReplylistBean {
        /**
         * replyparentid : 3
         * usericon :
         * replycontent : %E5%9B%9E%E5%A4%8D%E5%86%85%E5%AE%B9
         * replyid : 4
         * replyaddtime : 2019-06-25 07:31:52
         * replyuserid : 2
         * replyworksid : 1
         * usernickname : 13681998586
         */

        private String replyparentid;
        private String usericon;
        private String replycontent;
        private String replyid;
        private String replyaddtime;
        private String replyuserid;
        private String replyworksid;
        private String usernickname;

        public String getReplyparentid() {
            return replyparentid;
        }

        public void setReplyparentid(String replyparentid) {
            this.replyparentid = replyparentid;
        }

        public String getUsericon() {
            return usericon;
        }

        public void setUsericon(String usericon) {
            this.usericon = usericon;
        }

        public String getReplycontent() {
            return replycontent;
        }
        public String getReplyString() {
            String strUTF8 =replycontent;
            try {
                strUTF8  = URLDecoder.decode(replycontent, "UTF-8");

            } catch (UnsupportedEncodingException e) {
                return replycontent;
            }
            return getUsernickname()+":"+strUTF8;

        }


        public void setReplycontent(String replycontent) {
            this.replycontent = replycontent;
        }

        public String getReplyid() {
            return replyid;
        }

        public void setReplyid(String replyid) {
            this.replyid = replyid;
        }

        public String getReplyaddtime() {
            return replyaddtime;
        }

        public void setReplyaddtime(String replyaddtime) {
            this.replyaddtime = replyaddtime;
        }

        public String getReplyuserid() {
            return replyuserid;
        }

        public void setReplyuserid(String replyuserid) {
            this.replyuserid = replyuserid;
        }

        public String getReplyworksid() {
            return replyworksid;
        }

        public void setReplyworksid(String replyworksid) {
            this.replyworksid = replyworksid;
        }

        public String getUsernickname() {
            return com.example.apple.ddhr_new.utils.StringUtil.utfString(usernickname);

        }

        public void setUsernickname(String usernickname) {
            this.usernickname = usernickname;
        }
    }
}
